/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.klikmee.sms.core.model;

import java.io.Serializable;
import java.text.MessageFormat;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Lob;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 * 
 * @author makcro
 */
@Entity
@Table(name = "provider")
@NamedQueries({
		@NamedQuery(name = "Provider.findAll", query = "SELECT p FROM Provider p"),
		@NamedQuery(name = "Provider.findById", query = "SELECT p FROM Provider p WHERE p.id = :id"),
		@NamedQuery(name = "Provider.findByName", query = "SELECT p FROM Provider p WHERE p.name = :name") })
public class Provider implements Serializable {
	private static final long		serialVersionUID	= 1L;
	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@Basic(optional = false)
	@Column(name = "id", nullable = false)
	private Long					id;
	@Column(name = "name", length = 128)
	private String					name;
	@Lob
	@Column(name = "mobilePhonePrefixes", length = 2147483647)
	private String					mobilePhonePrefixes;

	@OneToMany(mappedBy = "provider")
	private List<OutgoingMessage>	outgoingMessageList;
	@OneToMany(cascade = CascadeType.ALL, mappedBy = "provider")
	private List<IncomingMessage>	incomingMessageList;

	public Provider() {
	}

	public Provider(Long id) {
		this.id = id;
	}

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getMobilePhonePrefixes() {
		return mobilePhonePrefixes;
	}

	public void setMobilePhonePrefixes(String mobilePhonePrefixes) {
		this.mobilePhonePrefixes = mobilePhonePrefixes;
	}

	public List<OutgoingMessage> getOutgoingMessageList() {
		return outgoingMessageList;
	}

	public void setOutgoingMessageList(List<OutgoingMessage> outgoingMessageList) {
		this.outgoingMessageList = outgoingMessageList;
	}

	public List<IncomingMessage> getIncomingMessageList() {
		return incomingMessageList;
	}

	public void setIncomingMessageList(List<IncomingMessage> incomingMessageList) {
		this.incomingMessageList = incomingMessageList;
	}

	@Override
	public int hashCode() {
		int hash = 0;
		hash += (id != null ? id.hashCode() : 0);
		return hash;
	}

	@Override
	public boolean equals(Object object) {
		if (!(object instanceof Provider)) {
			return false;
		}
		Provider other = (Provider) object;
		if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals( other.id ))) {
			return false;
		}
		return true;
	}

	@Override
	public String toString() {
		return MessageFormat.format( "Provider[{0}]", this.name );
	}

}
